<style type="text/css">
    .layui-form-select dl{z-index:9999;}
</style>
<form class="layui-form" action="{:url()}" method="post" id="editForm">
    <div class="layui-form-item">
        <label class="layui-form-label">项目名称</label>
        <div class="layui-input-inline w200">
            <select name="project_id" class="field-project_id" id="project_id" lay-filter="get_price" type="select" lay-verify="required">
                <option value="">请选择</option>
                {volist name="projects" id="vo"}
                    {if $formData && $formData['id'] == $vo.id}
                    <option value="{$vo.id}" data-price="{$vo.price}" selected>{$vo.name}</option>
                    {else}
                        <option value="{$vo.id}" data-price="{$vo.price}">{$vo.name}</option>
                    {/if}
                {/volist}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">数量</label>
        <div class="layui-input-inline w200">
            <input type="number"  class="layui-input field-num" name="num" id="num" value="1" lay-verify="number">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">是否赠送</label>
        <div class="layui-input-inline w200">
            <input type="radio" class="field-is_give" name="is_give" value="1" title="否" checked>
            <input type="radio" class="field-is_give" name="is_give" value="2" title="是">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">金额</label>
        <div class="layui-input-inline w200">
            <input type="text" class="layui-input field-price" name="price" id="price"  lay-verify="required" autocomplete="off" placeholder="请填写金额">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">项目分类</label>
        <div class="layui-input-inline w200">
            <input type="radio" class="field-type" name="type" value="1" title="实操项目" checked>
            <input type="radio" class="field-type" name="type" value="2" title="特殊项目">
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">顾问</label>
        <div class="layui-input-inline w200">
            <select name="adviser_id" class="field-adviser_id" type="select" lay-verify="required">
                <option value="">请选择</option>
                {$advisers|raw}
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">美容师</label>
        <div class="layui-input-inline w200">

            {volist name="technicians" id='vo'}
            <input type="checkbox" name="technician_ids[]" class="field-technician_ids" value="{$vo.id}" title="{$vo.nick}">
            {/volist}
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label">备注</label>
        <div class="layui-input-inline w200">
            <input type="text" class="layui-input field-bak" name="bak" lay-verify="required" autocomplete="off" placeholder="请填写备注">
        </div>
    </div>
    <span style="display:none" id="prices"></span>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" class="field-id" name="id">
            <input type="hidden" class="field-sub_id" name="sub_id" value="{$sub_id|default=""}">
            <button type="submit" class="layui-btn layui-btn-normal" hisi-data="{pop: true, refresh: true}" lay-submit="" lay-filter="formSubmit">提交</button>
            <a href="javascript:parent.layui.layer.closeAll();" class="layui-btn layui-btn-primary ml10">取消</a>
        </div>
    </div>
</form>
{include file="system@block/layui" /}
<script>
layui.use(['func','jquery','form'], function() {
    var $ = layui.jquery
        ,form = layui.form;
    // 编辑模式下表单自动赋值
    layui.func.assign({:json_encode($formData)});
    $('#num').on('change',function(){
        var num = $(this).val();
        var price = $('#prices').text();
        $('#price').val(price * num);
    })

    form.on('select(get_price)',function(data){
        var price = data.elem[data.elem.selectedIndex].dataset.price;
        $('#prices').text(price);
        var num = $('#num').val();
        $('#price').val(price * num);
    })
});
</script>
